/*
 * @(#)PoliticalNationTransformer.java
 * Date 2013-08-17
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.pix.transformer;

import javax.enterprise.context.ApplicationScoped;

import javax.inject.Inject;

import org.hl7.v3.PRPAMT201301UV02Nation;

import us.hornerscorners.lamppost.hl7v3common.utils.HL7Utils;

import us.hornerscorners.lamppost.model.patient.PoliticalNation;

import us.hornerscorners.lamppost.transformer.AbstractTransformer;


/**
 *
 * @author jim
 */
@ApplicationScoped
public class PoliticalNationTransformer
        extends AbstractTransformer<PRPAMT201301UV02Nation, PoliticalNation> {

    /** Field description */
    @Inject
    private CodedElementTransformer codedElementTransformer;

    /**
     * Constructs ...
     *
     */
    public PoliticalNationTransformer() {
        super();
    }

    /**
     * Method description
     *
     *
     * @param prpaNation
     *
     * @return
     */
    @Override
    public PoliticalNation transform(PRPAMT201301UV02Nation prpaNation) {

        PoliticalNation result = null;

        if (prpaNation != null) {

            result = new PoliticalNation();

            result.setCountryCode(
                this.codedElementTransformer.transform(prpaNation.getCode()));

            if (prpaNation.getName() != null) {

                result.setName(
                    HL7Utils.parseFirstSerializable(prpaNation.getName().getContent()));
            }
        }

        return result;
    }
}
